package xyz.whiteblue.kit;

import net.sf.json.JSONObject;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by WhiteBlue on 15/6/14.
 */
public class JsonKit {

    public static void renderJsonObject(HttpServletResponse response, Object target) {
        try {
            ServletOutputStream outputStream = response.getOutputStream();
            JSONObject json = JSONObject.fromObject(target);
            outputStream.print(json.toString());
            outputStream.flush();
            outputStream.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
